home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / utils / console / svgatext.3 / svgatext / SVGATextMode-1.3 / XFREE / patches / ICD2061_et4000.patch < prev    next >
Encoding:
Text File  |  1996-02-24  |  4.0 KB  |  164 lines

  1. --- common_hw/I2061Aalt.c.original    Wed Feb 14 20:21:11 1996
  2. +++ common_hw/I2061Aalt.c    Mon Feb 19 19:48:24 1996
  3. @@ -29,17 +29,18 @@
  4.  #endif
  5.  static void wait_vb();
  6.  static void wrt_clk_bit(unsigned int value);
  7. -static void init_clock(unsigned long setup, unsigned short crtcport);
  8. +static void s3_init_clock(unsigned long setup,  unsigned short crtcport);
  9. +static void et4000_init_clock(unsigned long setup);
  10.  #else
  11.  #if 0
  12.  static void prtbinary();
  13.  #endif
  14.  static void wait_vb();
  15.  static void wrt_clk_bit();
  16. -static void init_clock();
  17. +static void s3_init_clock();
  18.  #endif
  19.  
  20. -void AltICD2061SetClock(frequency, select)
  21. +static unsigned long AltICD2061CalcClock(frequency, select)
  22.  register long   frequency;               /* in Hz */
  23.  int select;
  24.  {
  25. @@ -53,17 +54,6 @@
  26.     double f0;
  27.     unsigned int p, q;
  28.     unsigned int bestp=0, bestq=0, bestm=0, besti=0;
  29. -   unsigned char tmp;
  30. -
  31. -   crtcaddr=(inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
  32. -
  33. -
  34. -   outb(crtcaddr, 0x11);    /* Unlock CRTC registers */
  35. -   tmp = inb(crtcaddr + 1);
  36. -   outb(crtcaddr + 1, tmp & ~0x80);
  37. -
  38. -   outw(crtcaddr, 0x4838);    /* Unlock S3 register set */
  39. -   outw(crtcaddr, 0xA039);
  40.  
  41.     clknum = select;
  42.  
  43. @@ -113,10 +103,51 @@
  44.     realval = (fvco * bestp) /  bestq;
  45.     dwv = ((((((long)besti << 7) | (bestp-3)) << 3) | bestm) << 7) | (bestq-2);
  46.  
  47. -/*
  48. - * Write ICD 2061A clock chip
  49. - */
  50. -   init_clock(((unsigned long)dwv) | (((long)clknum) << 21), crtcaddr);
  51. +#if 0
  52. +   fprintf(stderr, "I2061Aalt.c: freq %ld, clknum %d\n", (((4*14318lu*bestp/bestq)>>bestm)+1)>>1,
  53. +       clknum);
  54. +#endif
  55. +   return (((unsigned long)dwv) | (((long)clknum) << 21));
  56. +}
  57. +
  58. +
  59. +void AltICD2061SetClock(frequency, select)
  60. +register long   frequency;               /* in Hz */
  61. +int select;
  62. +{
  63. +   unsigned char tmp;
  64. +
  65. +   crtcaddr=(inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
  66. +
  67. +   outb(crtcaddr, 0x11);    /* Unlock CRTC registers */
  68. +   tmp = inb(crtcaddr + 1);
  69. +   outb(crtcaddr + 1, tmp & ~0x80);
  70. +
  71. +   outw(crtcaddr, 0x4838);    /* Unlock S3 register set */
  72. +   outw(crtcaddr, 0xA039);
  73. +   /* Write ICD 2061A clock chip */
  74. +   s3_init_clock(AltICD2061CalcClock(frequency, select), crtcaddr);
  75. +
  76. +   wait_vb();
  77. +   wait_vb();
  78. +   wait_vb();
  79. +   wait_vb();
  80. +   wait_vb();
  81. +   wait_vb();
  82. +   wait_vb();        /* 0.10 second delay... */
  83. +}
  84. +
  85. +void Et4000AltICD2061SetClock(frequency, select)
  86. +register long   frequency;               /* in Hz */
  87. +int select;
  88. +{
  89. +   crtcaddr=(inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
  90. +
  91. +   /* Write ICD 2061A clock chip */
  92. +   et4000_init_clock(AltICD2061CalcClock(frequency, select));
  93. +   
  94. +   /* select the clock */
  95. +   outb(0x3C2,(inb(0x3CC) & 0xF3) | ((select << 2) & 0x0C));
  96.  
  97.     wait_vb();
  98.     wait_vb();
  99. @@ -158,9 +189,9 @@
  100.  
  101.  
  102.  #if NeedFunctionPrototypes
  103. -static void init_clock(unsigned long setup, unsigned short crtcport)
  104. +static void s3_init_clock(unsigned long setup, unsigned short crtcport)
  105.  #else
  106. -static void init_clock(setup, crtcport)
  107. +static void s3_init_clock(setup, crtcport)
  108.     unsigned long setup;
  109.     unsigned short crtcport;
  110.  #endif
  111. @@ -247,3 +278,36 @@
  112.     for (j=2; --j; )
  113.        inb(0x200);
  114.     }
  115. +
  116. +
  117. +/*
  118. + *  ET4000 ICD2061 (Diamond Stealth 32) clock setting code.
  119. + *    Original by Frank Klemm
  120. + *    Linux port by Ray Balister.
  121. + *    various improvements by Peter Chang
  122. + *    included in XFREE code base by Koen Gadeyne
  123. + */
  124. +
  125. +static void et4000_init_clock(unsigned long setup)
  126. +{
  127. +    register unsigned char a=inb(0x3CC) & ~0x0C;
  128. +    register unsigned i;
  129. +    unsigned long m;
  130. +
  131. +#define S(x)    outb(0x3C2,a | 4*(x))
  132. +
  133. +    for (i=0; i<5; i++)
  134. +      S(2), S(3);
  135. +    for (i=0; i<2; i++)
  136. +      S(0), S(1);
  137. +    for (i=0, m=1; i<24; i++, m+=m)
  138. +      if (setup & m)
  139. +    S(1), S(0), S(2), S(3);
  140. +      else
  141. +    S(3), S(2), S(0), S(1);
  142. +    S(3), S(2), S(3);
  143. +    S(3);
  144. +
  145. +#undef S
  146. +
  147. +}
  148. --- common_hw/xf86_HWlib.h.original    Wed Feb 14 21:19:46 1996
  149. +++ common_hw/xf86_HWlib.h    Wed Feb 14 21:17:20 1996
  150. @@ -61,6 +61,13 @@
  151.  #endif
  152.  );
  153.  
  154. +extern void Et4000AltICD2061SetClock(
  155. +#if NeedFunctionPrototypes
  156. +    long,
  157. +    int
  158. +#endif
  159. +);
  160. +
  161.  /* ICD2061Acal.c */
  162.  extern long ICD2061ACalcClock(
  163.  #if NeedFunctionPrototypes
  164.